﻿@page "/counter"
@attribute [XTabPageAttribute("Counter")]

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

<div class="row mt-2">
    <div class="col-12">
        <button class="btn btn-primary" @onclick="ButtonCloseTabAsync">Close Tab</button>
    </div>
</div>

@code {

    [CascadingParameter]
    public XTabs XTabs { get; set; }

    private int currentCount = 0;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        await base.OnAfterRenderAsync(firstRender);
    }
    private void IncrementCount()
    {
        currentCount++;
    }

    private Task ButtonCloseTabAsync()
       => XTabs.CloseTabByTitleAsync("Counter");
}